<?php

namespace App\Http\Controllers\user;

use App\Dao\CategoryDao;
use App\Dao\ProjectDao;
use App\Exceptions\SysExceptions;
use App\Services\Code;

class ProjectsController extends BaseController
{

    public function get_projects(): array
    {
        return Code::message('',200,ProjectDao::get_projects(array_merge(request()->all(),[
            'product_type'=>0
        ])));
    }



    public function get_project_info(): array
    {
        ProjectDao::get_projects_builder([
            'project_id'=>request('project_id')
        ])->increment('show_nums',1);
        return Code::message('',200,ProjectDao::getOne(array_merge([
            'b_user_id'=>getUserToken(),

        ],request()->all()),1));
    }


    public function add_project_log(): array
    {
        return Code::message('',200,ProjectDao::add_project_log(array_merge([
            'user_id'=>getUserToken(),
            'project_id'=>request('project_id')
        ])));
    }


    public function get_categorys(): array
    {
        return Code::message('',200,CategoryDao::get_datas());
    }


    public function get_project_pass(): array
    {
        return Code::message('',200,ProjectDao::get_project_pass_list());
    }


    /**
     * @throws SysExceptions
     */
    public static function recive_pass(): array
    {
        $params = array_merge([
            'user_id'=>getUserToken()
        ],request()->all());
        ProjectDao::recive_pass($params);
        return Code::message('',200);
    }


    public function get_project_log(): array
    {
        return Code::message('',200,ProjectDao::get_projects_log([
            'user_id'=>getUserToken()
        ]));
    }


}
